<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .table-a{
            width: 100%;
        }
        .table-a tr{
            line-height: 30px;
            border-bottom: 1px solid #101010;
        }
    </style>
</head>
<body>
<div style="width: 1000px;height: 300px;margin: 0 auto;text-align: center">
<p><input type="text" id="text"><button id="btn" style="margin-left: 20px">查询</button></p>
<table id="table-a" class="table-a">
<tr>
    <th width="80%">内容</th>
    <th width="20%">code</th>
</tr>
</table>
</div>
</body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
    $('#btn').click(function () {
        $('#table-a tr').not(':eq(0)').remove();
        var texs=$('#text').val();
        if(texs.length==0){
            return false;
        }
        var url="{:Url('admin/diseases/showmessage')}"
        $.ajax({
            url:url,
            type:'post',
            data:{'text':texs},
            success:function (res) {
                var res=JSON.parse(res);
                console.log(res);
                var table=muban(res);
                $('#table-a').append(table);
            },
            error:function (res) {
                console.log(res);
            }
        })
    })
    function muban(data) {
        var str='';
        $.each(data,function (i,k) {
            str=str+"<tr><td>"+k.desc+"</td><td>"+k.code+"</td></tr>"
        })
        return str;
    }
</script>
</html>